@extends('layout.admin.index')
@section('content')


<div class="panel admin-panel">
    <div class="panel-head">
    	<strong class="icon-reorder"> 内容列表</strong>
    	<a href="/" style="float:right; display:none;">添加字段</a>
    </div>
    <div class="padding border-bottom">
        <ul class="search" style="padding-left:10px;">
	        <li>
                <a class="button border-main icon-plus-square-o" href="/admin/photo/add"> 添加内容</a>
            </li>
            <li>
                <a  href="#"> 显示条数</a>
            </li>
            <form action="/admin/photo/index" method="get">
                <li>                    
                    <select name="count" class="input" style="width:50px; line-height:17px;" onchange="changesearch()">
                        <option value="1" @if(!empty($request['count']) && $request['count'] == 1) selected @endif>1</option>
                        <option value="2" @if(!empty($request['count']) && $request['count'] == 2) selected @endif>2</option>
                        <option value="4" @if(!empty($request['count']) && $request['count'] == 4) selected @endif>4</option>
                        <option value="8" @if(!empty($request['count']) && $request['count'] == 8) selected @endif>8</option>
                        <option value="16"@if(!empty($request['count']) && $request['count'] == 16) selected @endif>16</option>
                    </select>
                </li>
		        <li>
		            <input type="text" placeholder="请输入描述中的关键字进行搜索" name="search" value="{{ $request['search'] or ''}}" class="input" style="width:250px; line-height:17px;display:inline-block" />
		              <!--  <a href="javascript:void(0)" class="button border-main icon-search" onclick="changesearch()" > 搜索</a> -->
                    <input type="submit" value="搜索" class="button border-main icon-search">
		        </li>
            </form>
        </ul>
    </div>
    <form method="post" action="/admin/photo/delall" id="listform">
        {{ csrf_field() }}
	    <table class="table table-hover text-center">
		    <tr>
		        <th width="70" style="text-align:left; padding-left:20px;">ID</th>     
		        <th>图片</th>
                <th>超链接</th>
                <th>描述</th>
		        <th width="10%">状态</th>
		        <th width="10%">创建时间</th>
		        <th width="10%">更新时间</th>
		        <th width="200">操作</th>
		    </tr>
	        @foreach($data as $k => $v)
	        <tr>
				<td style="text-align:left; padding-left:20px;"><input type="checkbox" name="id[]" value="{{ $v['id'] }}" />
				{{ $v['id'] }}</td>							
				<td width="10%"><a href="{{ $v['photo_link'] }}"><img src="/web/images/{{ $v['photo_name'] }}" alt="" width="70" height="50" /></a></td>
                <td>{{ $v['photo_link'] }}</td>
                <td>{{ $v['photo_description'] }}</td>
                <td>
                    @if($v['photo_status'] == 1)
                        <font style="color:green;">已开启</font>
                    @else
                        <font style="color:red;">已禁用</font>
                    @endif
                </td>
				<td>{{ $v['photo_createtime'] }}</td>
				<td>{{ $v['photo_changetime'] }}</td>
				<td><div class="button-group"> <a class="button border-main" href="/admin/photo/edit/{{ $v['id'] }}"><span class="icon-edit"></span> 修改</a> <a class="button border-red" href="/admin/photo/delete/{{ $v['id'] }}" onclick="return del(1,1,1)"><span class="icon-trash-o"></span> 删除</a> </div></td>
	        </tr> 
	        @endforeach  
			<tr>
				<td style="text-align:left; padding:19px 0;padding-left:20px;"><input type="checkbox" id="checkall"/>
				  全选 </td>
				<td colspan="7" style="text-align:left;padding-left:20px;"> 
                    <input type="submit" value="删除" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="DelSelect()">
                </td>		  
			</tr>
			<tr>
				<td colspan="8">
                        <div class="pagelist">
                            <!-- <a href="">上一页</a>
                            <span class="current">1</span>
                            <a href="">2</a>
                            <a href="">3</a>
                            <a href="">下一页</a>
                            <a href="">尾页</a> </div></td> -->

                            {!! $data->appends($request)->render() !!}
                        </div>
			</tr>
	    </table>
    </form>
</div>


    <script type="text/javascript">

    //搜索
    function changesearch(){	
    		
    }

    //单个删除
    function del(id,mid,iscid){
    	if(confirm("您确定要删除吗?")){
    		
    	}
    }

    //全选
    $("#checkall").click(function(){ 
      $("input[name='id[]']").each(function(){
    	  if (this.checked) {
    		  this.checked = false;
    	  }
    	  else {
    		  this.checked = true;
    	  }
      });
    })

    //批量删除
    function DelSelect(){
    	var Checkbox=false;
    	 $("input[name='id[]']").each(function(){
    	  if (this.checked==true) {		
    		Checkbox=true;	
    	  }
    	});
    	if (Checkbox){
    		var t=confirm("您确认要删除选中的内容吗？");
    		if (t==false) return false;		
    		$("#listform").submit();		
    	}
    	else{
    		alert("请选择您要删除的内容!");
    		return false;
    	}
    }

    //批量排序
    function sorts(){
    	var Checkbox=false;
    	 $("input[name='id[]']").each(function(){
    	  if (this.checked==true) {		
    		Checkbox=true;	
    	  }
    	});
    	if (Checkbox){	
    		
    		$("#listform").submit();		
    	}
    	else{
    		alert("请选择要操作的内容!");
    		return false;
    	}
    }


    //批量首页显示
    function changeishome(o){
    	var Checkbox=false;
    	 $("input[name='id[]']").each(function(){
    	  if (this.checked==true) {		
    		Checkbox=true;	
    	  }
    	});
    	if (Checkbox){
    		
    		$("#listform").submit();	
    	}
    	else{
    		alert("请选择要操作的内容!");		
    	
    		return false;
    	}
    }

    //批量推荐
    function changeisvouch(o){
    	var Checkbox=false;
    	 $("input[name='id[]']").each(function(){
    	  if (this.checked==true) {		
    		Checkbox=true;	
    	  }
    	});
    	if (Checkbox){
    		
    		
    		$("#listform").submit();	
    	}
    	else{
    		alert("请选择要操作的内容!");	
    		
    		return false;
    	}
    }

    //批量置顶
    function changeistop(o){
    	var Checkbox=false;
    	 $("input[name='id[]']").each(function(){
    	  if (this.checked==true) {		
    		Checkbox=true;	
    	  }
    	});
    	if (Checkbox){		
    		
    		$("#listform").submit();	
    	}
    	else{
    		alert("请选择要操作的内容!");		
    	
    		return false;
    	}
    }


    //批量移动
    function changecate(o){
    	var Checkbox=false;
    	 $("input[name='id[]']").each(function(){
    	  if (this.checked==true) {		
    		Checkbox=true;	
    	  }
    	});
    	if (Checkbox){		
    		
    		$("#listform").submit();		
    	}
    	else{
    		alert("请选择要操作的内容!");
    		
    		return false;
    	}
    }

    //批量复制
    function changecopy(o){
    	var Checkbox=false;
    	 $("input[name='id[]']").each(function(){
    	  if (this.checked==true) {		
    		Checkbox=true;	
    	  }
    	});
    	if (Checkbox){	
    		var i = 0;
    	    $("input[name='id[]']").each(function(){
    	  		if (this.checked==true) {
    				i++;
    			}		
    	    });
    		if(i>1){ 
    	    	alert("只能选择一条信息!");
    			$(o).find("option:first").prop("selected","selected");
    		}else{
    		
    			$("#listform").submit();		
    		}	
    	}
    	else{
    		alert("请选择要复制的内容!");
    		$(o).find("option:first").prop("selected","selected");
    		return false;
    	}
    }

    </script>

@endsection